Skip to content

ports/target: don't crash on transport to an uninitialized bridge#84

Closed
Matheus Tavares Bernardino @ Qualcomm (quic-mathbern) wants to merge 1 commit into
qualcomm:mainfrom
quic-mathbern:mathbern/fix-null-def
Closed

ports/target: don't crash on transport to an uninitialized bridge#84
Matheus Tavares Bernardino @ Qualcomm (quic-mathbern) wants to merge 1 commit into
qualcomm:mainfrom
quic-mathbern:mathbern/fix-null-def

Conversation

@quic-mathbern

Copy link
Copy Markdown
Contributor

A QemuTargetSocket's bridge is only wired up to its QEMU instance once
init()/init_with_mr() runs. Before that, m_inst is null and the socket
cannot service a transaction.

Nothing stops a transaction from arriving early, though: a gs::loader
loads its image at end_of_elaboration, and that access can be routed by
the router to a bridge that hasn't been initialized yet. b_transport
then dereferences the null m_inst and segfaults.

Bail out early with TLM_OK_RESPONSE when the bridge is uninitialized so
the access is a harmless no-op instead of a crash.

Signed-off-by: Matheus Tavares Bernardino matheus.bernardino@oss.qualcomm.com

A QemuTargetSocket's bridge is only wired up to its QEMU instance once
init()/init_with_mr() runs. Before that, m_inst is null and the socket
cannot service a transaction.

Nothing stops a transaction from arriving early, though: a gs::loader
loads its image at end_of_elaboration, and that access can be routed by
the router to a bridge that hasn't been initialized yet. b_transport
then dereferences the null m_inst and segfaults.

Bail out early with TLM_OK_RESPONSE when the bridge is uninitialized so
the access is a harmless no-op instead of a crash.

Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
@quic-mathbern

Copy link
Copy Markdown
Contributor Author

CC
Mark Burton (@markfoodyburton)
Brian Cain (@androm3da)
mahmdkamel

(For some reason, I'm not allowed to ask for reviews)

@androm3da

Copy link
Copy Markdown
Member

a gs::loader loads its image at end_of_elaboration, and that access can be routed by the router to a bridge that hasn't been initialized yet. b_transport then dereferences the null m_inst and segfaults.

But does that indicate some kind of misconfiguration that we shouldn't try to support?

Or just some configuration that we should support that none of the tests expose?

Mark Burton (@markfoodyburton) ?

@markfoodyburton

Copy link
Copy Markdown
Contributor

a gs::loader loads its image at end_of_elaboration, and that access can be routed by the router to a bridge that hasn't been initialized yet. b_transport then dereferences the null m_inst and segfaults.

But does that indicate some kind of misconfiguration that we shouldn't try to support?

Or just some configuration that we should support that none of the tests expose?

Mark Burton (Mark Burton (@markfoodyburton)) ?

I agree, this is very strange - why is (e.g. the loader) trying to load to a qemu target like this?
I also agree it seems odd that it's so "late" to do the bind, I can't remember why that is, but I seem to remember there isn't much we can do about that.
Where I very much differ with the patch is that, IF somebody is trying to load to a qemu device before initialisation, then, simply ignoring it is probably very bad. At the least I would expect to return with an error, ideally generate a warning, possibly stop the simulation.

@mahmdkamel

Copy link
Copy Markdown
Contributor

a gs::loader loads its image at end_of_elaboration, and that access can be routed by the router to a bridge that hasn't been initialized yet. b_transport then dereferences the null m_inst and segfaults.

But does that indicate some kind of misconfiguration that we shouldn't try to support?
Or just some configuration that we should support that none of the tests expose?
Mark Burton (Mark Burton (Mark Burton (@markfoodyburton))) ?

I agree, this is very strange - why is (e.g. the loader) trying to load to a qemu target like this? I also agree it seems odd that it's so "late" to do the bind, I can't remember why that is, but I seem to remember there isn't much we can do about that. Where I very much differ with the patch is that, IF somebody is trying to load to a qemu device before initialisation, then, simply ignoring it is probably very bad. At the least I would expect to return with an error, ideally generate a warning, possibly stop the simulation.

I agree on that, when we load to a qemu device very early, most of time this means we have an issue in the configurations of one or more target sockets, so I would prefer to SCP_FATAL with a meaningful message in this case instead of silently return a TLM OK response.

@quic-mathbern

Copy link
Copy Markdown
Contributor Author

[...]
I agree on that, when we load to a qemu device very early, most of time this means we have an issue in the configurations of one or more target sockets, so I would prefer to SCP_FATAL with a meaningful message in this case instead of silently return a TLM OK response.

Indeed, rethinking this, a silent ignore doesn't seem like the best option. I'll close the MR for now (the issue I was seeing was already resolved with another PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants